package com.heima.gateway.filter;

import lombok.Data;
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.OrderedGatewayFilter;
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;

import java.util.List;

//@Component
public class PrintAnyGatewayFilterFactory extends AbstractGatewayFilterFactory<Object> {
    @Override
    public GatewayFilter apply(Object config) {
        return null;
    }
    //@Override
    //public GatewayFilter apply(Object config) {
    //    return new OrderedGatewayFilter((exchange, chain) -> {
    //        // 获取config值
    //        String a = config.getA();
    //        String b = config.getB();
    //        String c = config.getC();
    //        // 编写过滤器逻辑
    //        System.out.println("a = " + a);
    //        System.out.println("b = " + b);
    //        System.out.println("c = " + c);
    //        // 放行
    //        return chain.filter(exchange);
    //    },100);
    //
    //
    //}
    //
    //// 自定义配置属性，成员变量名称很重要，下面会用到
    //@Data
    //static class Config{
    //    private String a;
    //    private String b;
    //    private String c;
    //}
    //// 将变量名称依次返回，顺序很重要，将来读取参数时需要按顺序获取
    //@Override
    //public List<String> shortcutFieldOrder() {
    //    return List.of("a", "b", "c");
    //}
    //// 返回当前配置类的类型，也就是内部的Config
    //@Override
    //public Class<Config> getConfigClass() {
    //    return Config.class;
    //}


    //@Override
    //public GatewayFilter apply(Object config) {
    //    return (exchange, chain) -> {
    //        // 获取请求
    //        ServerHttpRequest request = exchange.getRequest();
    //        // 编写过滤器逻辑
    //        System.out.println("过滤器执行了");
    //        // 放行
    //        return chain.filter(exchange);
    //    };
    //}


}
